<!DOCTYPE html>
<html lang="zh"   xmlns:th="http://www.thymeleaf.org"
   xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"
	th:with="blogConfig=${@configTag.getConfigValueMap('zgblog')},unionList=${@unionTag.listCmsUnions('','','','DEFAULT',blogConfig['oly.web.theme.zgblog.union.order'],1,blogConfig['oly.web.theme.zgblog.union.size'])}">

<head>
	<th:block th:include="zgblog/blog_include :: blogHeader(title=${columnremark +' - '+blogConfig['oly.web.title']},
	keywords=${columnkeywords},
	description=${columndescription},
	blogConfig=${blogConfig})" />

	<style>
		.prodect-box {
			height: 108px;
			padding: 4px;
		}

		.product-title-wrap {
			height: 50px;
			padding: 5px;
			overflow: hidden;
		}

		.couponlink,
		.salescount {
			float: right;
		}

		.aftercoupon {
			color: #e74737;
		}

		.aftercoupon>span {
			font-size: 20px;
		}

		.shop-img {
			height: 280px;
			width: 100%;
		}

		.layui-form-radio {
			margin: 0;
		}

		.wordbox {
			position: relative;
		}

		.box {
			position: absolute;
			text-align: center;
			word-wrap: break-word;
			overflow: hidden;
			border: 2px solid #fff;
		}

		.box a {
			color: #fff;
			text-decoration: none;
			display: inline-block;
			width: 100%;
			height: 100%;
		}

		.box-wrap {
			min-width: 340px;
			min-height: 400px;
			padding: 10px;
		}

		#box-fixedWidth1 {
			position: absolute;
			top: 150px;
		}
	</style>

</head>

<body>
	<th:block th:include="zgblog/blog_include::blogMainColumn()" />
	<!-- 主体部分 -->
	<section class="zgblog-main-box">
		<div class="layui-row ">
			<div class="layui-col-md8 layui-col-md-offset1 zgblog-left-box" id="miao-left">
				<div class="zgblog-left-content">
					<div class="layui-row">
						<div class="layui-col-md12 zgblog-box">
							<div class="layui-card-body" style="background-color: white;min-height: 100vh">
								<div class="layui-row layui-font-gray layui-form" id="searchForm" lay-filter="sf"
									style="line-height: 50px;text-align: center;">
									<div class="layui-col-md1 layui-col-xs3 layui-col-sm3 shop-order"
										data-sort="DEFAULT">
										<a href="javascript:void(0)"><span>排序：</span><span style="color:red ;"
												class="order-title">综合</span></a>
									</div>
									<div class="layui-col-md1 layui-col-xs3 layui-col-sm3 shop-order"
										data-sort="SHOP_SALES">
										<a href="javascript:void(0)"><span class="order-title">销量</span><span
												class="layui-table-sort layui-inline"><i
													class="layui-edge layui-table-sort-desc" title="降序"></i></span></a>
									</div>
									<div class="layui-col-md1 layui-col-xs3 layui-col-sm3 shop-order"
										data-sort="COUPON_PRICE">
										<a href="javascript:void(0)"><span class="order-title">优惠</span><span
												class="layui-table-sort layui-inline"><i
													class="layui-edge layui-table-sort-desc" title="降序"></i></span></a>
									</div>
									<div class="layui-col-md1 layui-col-xs3 shop-order" data-sort="SHOP_PRICE">
										<a href="javascript:void(0)"><span class="order-title">价格</span><span
												class="layui-table-sort layui-inline">
												<i class="layui-edge layui-table-sort-desc" title="降序"></i></span></a>
									</div>
									<div class="layui-col-md4 layui-col-xs12 layui-col-sm12">
										<input type="radio" title="所有" lay-filter="fairy-spec-filter" value=""
											checked="" name="unionType">
										<div class="layui-unselect layui-form-radio layui-form-checked">
											<span>所有</span><i class="layui-icon layui-icon-ok"></i>
										</div><input type="radio" title="淘宝" lay-filter="fairy-spec-filter" value="TB"
											name="unionType">
										<div class="layui-unselect layui-form-radio"><span>淘宝</span><i
												class="layui-icon layui-icon-ok"></i></div><input type="radio"
											title="拼多多" lay-filter="fairy-spec-filter" value="PDD" name="unionType">
										<div class="layui-unselect layui-form-radio"><span>拼多多</span><i
												class="layui-icon layui-icon-ok"></i></div>
										<input type="radio" title="京东" lay-filter="fairy-spec-filter" value="JD"
											name="unionType">
										<div class="layui-unselect layui-form-radio"><span>京东</span><i
												class="layui-icon layui-icon-ok"></i></div>
									</div>
									<span class="layui-btn layui-btn-primary layui-btn-sm" id="catBtn"
										style="border:none;position: absolute;left: 0;top: 0;"><i
											class="layui-icon layui-icon-menu-fill layui-font-20" title="分类"></i></span>
								</div>
								<div class="layui-table-body" style="margin-top: 20px;">
									<div class="layui-row" id="shop-box">
										<div class="layui-col-md3" style="padding: 4px;" th:each="union:${unionList}">
											<div class="post-list-item-container" style="padding:5px ;">
												<img class="item-thumb  bg-deepgrey shop-img"
													th:src="${union.shopImg}" />
												<div class="prodect-box">
													<p class="product-title-wrap">
														<span class="layui-badge layui-bg-blue"
															th:if="${union.unionType=='TB'}">淘宝</span>
														<span class="layui-badge layui-bg-green"
															th:if="${union.unionType=='PDD'}">拼多多</span>
														<span class="layui-badge layui-bg-cyan"
															th:if="${union.unionType=='JD'}">京东</span><a
															th:href="${#strings.isEmpty(union.couponUrl)?union.taokeUrl : union.couponUrl}"
															th:text="${union.shopName}">5同仁堂染发剂自己在家5同仁堂染发剂自己在家植物纯染发膏盖白发黑茶天然无刺激品牌正植物纯染发膏盖白发黑茶天然无刺激品牌正</a>
													</p>
													<div class="salesinfo layui-font-gray">
														<del class="origin-price"
															th:text="${'¥'+union.shopPrice}">¥72</del>
														<span class="salescount" th:text="${union.shopSales+'月销'}">16月销
														</span>
													</div>
													<div class="msginfo-row">
														<span class="aftercoupon"><span
																th:text="${#strings.isEmpty(union.couponPrice)?'¥'+union.shopPrice : '卷后¥'+(union.shopPrice-union.couponPrice)}">28</span>&nbsp;&nbsp;
														</span>
														<a class="couponlink layui-btn-sm layui-btn-radius layui-btn-danger"
															th:href="${#strings.isEmpty(union.couponUrl)?union.taokeUrl : union.couponUrl}"
															target="_blank"
															th:text="${#strings.isEmpty(union.couponUrl)?'立即前往' : '立即领卷'}">领20元券</a>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div id="pageDemo" style="text-align: center;">
									<div class="layui-box layui-laypage layui-laypage-default"><a href="javascript:;"
											id="nextBtn">加载更多</a></div>
								</div>
							</div>
						</div>
					</div>

				</div>
			</div>
			<!-- 主体部分右边 -->
			<div class="layui-col-md3 zgblog-right-box">
				<div class="layui-row">
					<div class="layui-col-md12">
						<div class="layui-tab layui-tab-brief">
							<ul class="layui-tab-title" style="text-align: center">
								<li class="layui-this">福利文章</li>
								<li>省钱教程</li>
							</ul>
							<div class="layui-tab-content">
								<div class="layui-tab-item layui-card-body layui-show">
									<th:block
										th:include="zgblog/blog_include::blogArticleSortText(articles=${@articleCountSortTag.listWebArticleOrderByTagId(1,blogConfig['oly.web.theme.zgblog.union.articleSize'],blogConfig['oly.web.theme.zgblog.union.youTag'],'','TIME','DESC')})" />
								</div>
								<div class="layui-tab-item layui-card-body">
									<th:block
										th:include="zgblog/blog_include::blogArticleSortText(articles=${@articleCountSortTag.listWebArticleOrderByTagId(1,blogConfig['oly.web.theme.zgblog.union.articleSize'],blogConfig['oly.web.theme.zgblog.union.wealTag'],'','TIME','DESC')})" />
								</div>
							</div>
						</div>
					</div>

					<div class="layui-col-md12">
						<div class="layui-card">
							<div class="layui-card-header">商品推荐</div>
							<div class="layui-card-body" id="side_con">
								<ul class="sidebar_content side_con">
									<li th:each="union,unionStatus:${@unionTag.listCmsUnionsByTag('',2,'DEFAULT','DESC',1,blogConfig['oly.web.theme.zgblog.union.tuiSize'])}"
										th:class="${unionStatus.index!=1}?'':'on'">
										<a th:href="${#strings.isEmpty(union.couponUrl)?union.taokeUrl : union.couponUrl}"
											th:title="${union.shopName}" target="_blank">
											<div class="hotcom-img">
												<img th:src="${union.shopImg}" th:alt="${union.shopName}">
											</div>
											<div class="hotcom-left">
												<div class="hot-com-title">
													<span th:class="${'num'+(unionStatus.index+1)}"
														th:text="${unionStatus.index+1}">1</span>
													<apan th:text="${union.shopName}">谷歌暂停与华为部分业务合作,华为:中国市场不受影响</apan>
												</div>
												<div class="hot-com-clock"><span
														th:text="${#strings.isEmpty(union.couponPrice)?'¥'+union.shopPrice : '卷后¥'+(union.shopPrice-union.couponPrice)}">511</span>
												</div>
											</div>
										</a>
									</li>
								</ul>
							</div>
						</div>
					</div>

					<div class="layui-col-md12">
						<div class="layui-card">
							<div class="layui-card-header">商品标签</div>
							<div class="layui-card-body" style="overflow: hidden">
								<div class="tagcloud" id="shopTag">
									<a th:each="tag:${@tagTag.listTagByType(5,'')}" th:data-tag="${tag.tagId}"
										href="javascript:void(0)" th:text="${tag.tagName}"></a>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
	<!-- 底部导航 -->
	<th:block th:include="zgblog/blog_include::blogBottom" />
	<th:block th:include="zgblog/blog_include::blog_footer_js" />
	<script th:src="@{/themes/zgblog/resources/js/tagAuto.js}"></script>

	<script type="text/html" id="shopItem">
		{{# layui.each(shopList, function(index, union){   }}
		<div class="layui-col-md3" style="padding: 4px;">
			<div class="post-list-item-container">
				<img class="item-thumb  bg-deepgrey shop-img"
					src="{{union.shopImg}}" />
				<div class="prodect-box">
					{{# if(union.couponUrl==null ||union.couponUrl==''){ }}
					<p class="product-title-wrap">
						{{# if(union.unionType=='TB'){ }}
						<span class="layui-badge layui-bg-blue">淘宝</span>
					    {{#   }else if(union.unionType=='PDD'){ }}
						<span class="layui-badge layui-bg-green">拼多多</span>
						{{#  }else if(union.unionType=='JD'){ }}
						<span class="layui-badge layui-bg-cyan">京东</span>
						{{#  } }}
						<a href="{{union.taokeUrl}}" >{{union.shopName}}</a>
					</p>
					<div class="salesinfo layui-font-gray">
						<del class="origin-price">¥{{union.shopPrice}}</del>
						<span class="salescount" >{{union.shopSales}}月销
						</span>
					</div>
					<div class="msginfo-row">
						<span class="aftercoupon"><span >¥{{union.shopPrice}}</span>&nbsp;&nbsp;
						</span>
						<a class="couponlink layui-btn-sm layui-btn-radius layui-btn-danger"
							href="{{union.taokeUrl}}"
							target="_blank">立即前往</a>
					</div>
					{{# } else{ }}
					<p class="product-title-wrap">
						{{# if(union.unionType=='TB'){ }}
						<span class="layui-badge layui-bg-blue">淘宝</span>
					    {{#   }else if(union.unionType=='PDD'){ }}
						<span class="layui-badge layui-bg-green">拼多多</span>
						{{#  }else if(union.unionType=='JD'){ }}
						<span class="layui-badge layui-bg-cyan">京东</span>
						{{#  } }}
						<a href="{{union.couponUrl}}" >{{union.shopName}}</a>
					</p>
					<div class="salesinfo layui-font-gray">
						<del class="origin-price">¥{{union.shopPrice}}</del>
						<span class="salescount" >{{union.shopSales}}月销
						</span>
					</div>
					<div class="msginfo-row">
						<span class="aftercoupon"><span >卷后¥{{union.shopPrice-union.couponPrice}}<span>&nbsp;&nbsp;
						</span>
						<a class="couponlink layui-btn-sm layui-btn-radius layui-btn-danger"
							href="{{union.couponUrl}}"
							target="_blank"> 立即领卷</a>
					</div>
					{{# }}}
				</div>
			</div>
		</div>
		{{# }) }}
	</script>

	<script type="text/html" id="shopCats">
		<div id="cat-box">
		{{# layui.each(cats, function(index, cat){ }}
		<span class="layui-badge layui-bg-blue" data-catId="{{cat.catId}}">{{cat.catName}}</span>
		{{# }) }}
		</div>
	</script>

	<script th:inline="JavaScript">
		var cats = [[${@categoryTag.listCmsCats(blogConfig['oly.web.theme.zgblog.union.catType'], blogConfig['oly.web.theme.zgblog.union.catId'], 1, '') }]];
		var words = [];
		for (let index = 0; index < cats.length; index++) {
			words[index] = {
				'title': cats[index].catName,
				'url': '#' + cats[index].catId
			}
		}
		var colors3 = ['#49B4E0', '#FCBDA2', '#EBADBD', '#D5C2AF', '#C0BDE5', '#CBCC7F', '#FFDA7F', '#8dd0c3', '#bbbfc6', '#a4d9ef', '#bbdb98'];
		var searchData = {
			sort: 'DEFAULT',
			order: 'DESC',
			cat: '',
			tag: '',
			unionType: '',
			pageSize: [[${ blogConfig['oly.web.theme.zgblog.union.size']}]],
			pageNum: 1
		}
		var shopList, bolNext = true;
		layui.use(['form', 'laytpl', 'layer'], function () {
			var form = layui.form, laytpl = layui.laytpl, layer = layui.layer;
			var bo = $("#shop-box");
			form.on('radio(fairy-spec-filter)', function (data) {
				searchData.unionType = data.value;
				searchData.pageNum = 1;
				bolNext = true;
				$("#nextBtn").text("加载更多!");
				bo.empty();
				listUnion();
			});
			$("#searchForm>.shop-order").click(function () {
				$("#searchForm>.shop-order .order-title").css('color', '');
				searchData.sort = $(this).data().sort;
				searchData.pageNum = 1;
				bolNext = true;
				$("#nextBtn").text("加载更多!");
				$(this).find(".order-title").css('color', 'red');
				bo.empty();
				listUnion();
			});
			//推广列表
			function listUnion() {
				$.get(ctx + "api/union/listUnion", searchData, function (res) {
					shopList = res.data;
					laytpl(shopItem.innerHTML).render(shopList, function (html) {
						bo.append(html);
					});
					if (res.data.length < searchData.pageSize) {
						bolNext = false;
						$("#nextBtn").text("没有更多了!");
					}
				});
			}
			// 加载更多
			$("#nextBtn").click(function () {
				if (bolNext) {
					searchData.pageNum += 1;
					listUnion();
				}
			});
			// 分类按钮
			$("#catBtn").click(function () {
				laytpl(shopCats.innerHTML).render(cats, function (html) {
					layer.open({
						type: 1,
						title: '分类列表',
						closeBtn: 0,
						shadeClose: true,
						content: '<div class="box-wrap"><div id="box-responsive" class="wordbox"></div></div>',
						success: function () {
							new WordBox('#box-responsive', {
								isLead: false,
								leadWord: null,
								words: words,
								colors: colors3,
								borderWidth: 2,
								isFixedWidth: false
							});
						}
					});
				});
			});

			$("#shopTag>a").click(function () {
				searchData.pageNum = 1;
				searchData.tag = $(this).data().tag;
				searchData.cat = '';
				bolNext = true;
				$("#nextBtn").text("加载更多!");
				bo.empty();
				listUnion();
			});

			$("body").on('click', "#box-responsive a", function () {
				searchData.cat = $(this).attr('href').replace('#', '');
				searchData.tag = '';
				searchData.pageNum = 1;
				bolNext = true;
				$("#nextBtn").text("加载更多!");
				bo.empty();
				listUnion();
				layer.closeAll();
			})
		});
	</script>

</body>

</html>